package org.come.control;

import org.come.Frame.GangsGuardJframe;
import org.come.action.NpcMenuAction;
import org.come.until.FormsManagement;

import com.tool.role.RoleData;

import io.netty.util.internal.StringUtil;

public class GangsGuardControl implements NpcMenuAction {

	@Override
	public void menuControl(String type) {
		if ("我要更换主守护".equals(type)) {
			mainGangsGuard();
		} else if ("我要更换副守护".equals(type)) {
			viceGangsGuard();
		}
	}

	/**
	 * 更改帮派主守护
	 */
	public void mainGangsGuard() {
		String[] v = "物理吸收|抗混乱|抗封印|抗昏睡|抗中毒|抗风|抗雷|抗水|抗火|抗鬼火|抗遗忘".split("\\|");
		for (int i = 0; i < 11; i++) {
			GangsGuardJframe.getGangsGuardJframe().getGangsGuardJpanel().getLabResistance()[i].setText("主" + v[i]);
		}
		String sh = RoleData.getRoleData().getLoginResult().getResistance();
		String[] kx = sh.split("\\|");
		String zhu = kx[0].substring(2);
		if(StringUtil.isNullOrEmpty(zhu)) {
			GangsGuardJframe.getGangsGuardJframe().getGangsGuardJpanel().getLabCrap().setText("很高兴为您服务，您目前没有主守护，请选择您的主守护。");	
		} else {
			GangsGuardJframe.getGangsGuardJframe().getGangsGuardJpanel().getLabCrap().setText("很高兴为您服务，您目前的主守护是【"+zhu+"】，请选择您要更换的主守护。");	
		}
			
		
		FormsManagement.showForm(53);
	}

	/**
	 * 更改帮派副守护
	 */
	public void viceGangsGuard() {
		String[] v = "物理吸收|抗混乱|抗封印|抗昏睡|抗中毒|抗震慑|抗风|抗雷|抗水|抗火|抗鬼火|抗遗忘".split("\\|");
		for (int i = 0; i < 11; i++) {
			GangsGuardJframe.getGangsGuardJframe().getGangsGuardJpanel().getLabResistance()[i].setText("副" + v[i]);
		}
		String sh = RoleData.getRoleData().getLoginResult().getResistance();
		String[] kx = sh.split("\\|");
		String fu = kx[1].substring(2);
		if(StringUtil.isNullOrEmpty(fu)) {
			GangsGuardJframe.getGangsGuardJframe().getGangsGuardJpanel().getLabCrap().setText("很高兴为您服务，您目前没有副守护，请选择您的副守护。");	
		} else {
			GangsGuardJframe.getGangsGuardJframe().getGangsGuardJpanel().getLabCrap().setText("很高兴为您服务，您目前的副守护是【"+fu+"】，请选择您要更换的副守护。");	
		}
		FormsManagement.showForm(53);

	}
}
